package cn.gong.movie.db;

import android.database.Cursor;
import android.database.sqlite.SQLiteOpenHelper;
import framework.base.db.BaseDb;
import framework.base.ui.ContextManager;

public class DbBase extends BaseDb {

	protected static final String INTEGER = "integer";
	protected static final String VARCHAR = "varchar";
	protected static final String PRIMARY_KEY = "primary key";
	protected static final String AUTOINCREMENT = "autoincrement";
	protected static final String ID_PK = INTEGER + " " + PRIMARY_KEY;
	protected static final String ID_PK_AUTO = INTEGER + " " + PRIMARY_KEY + " " + AUTOINCREMENT;

	protected DbBase() {
		super(new AppSQLiteOpenHelper(ContextManager.getInstance().getContext()));
	}

	// cursor相关
	protected String getCursorString(Cursor cursor, String columnName) {
		return cursor.getString(cursor.getColumnIndex(columnName));
	}

	protected int getCursorInt(Cursor cursor, String columnName) {
		return cursor.getInt(cursor.getColumnIndex(columnName));
	}

	protected long getCursorLong(Cursor cursor, String columnName) {
		return cursor.getLong(cursor.getColumnIndex(columnName));
	}

}
